#-*- coding: utf-8 -*-

import os
import argparse
import shutil


parse = argparse.ArgumentParser()
parse.add_argument('-id', type=str, default='None', help="primer id")

args = parse.parse_args()
primerid = args.id

os.makedirs('D:/wamp64/www/primer/Public/db/tmp/', exist_ok=True)
pswpath = 'D:/wamp64/www/primer/Public/db/blast.fasta'
tmppath = 'D:/wamp64/www/primer/Public/db/tmp/blast.fasta'

print(pswpath)

tmp_file = open(tmppath, "w")
flag = False
with open(pswpath) as f:
    lines = f.readlines()
    for line in lines:
        if line.find(primerid) > -1:
            flag = True
            continue
        if flag:
            flag = False
            continue
        tmp_file.write(line)

tmp_file.close()

tmp_file = open(tmppath, "r")
psw_file = open(pswpath, 'w')

shutil.copyfileobj(tmp_file,psw_file)

tmp_file.close()
psw_file.close()
